import Vue from 'vue';
import VueRouter from 'vue-router';
import HomeView from '../views/HomeView.vue';

Vue.use(VueRouter);

const routes = [
  // 路由重定向
  // / => /home
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView,
  },
  {
    path: '/movie',
    name: 'movie',
    component: () => import('@/views/MovieView.vue'),
  },
  {
    path: '/cinema',
    name: 'cinema',
    component: () => import('@/views/CinemaView.vue'),
  },
  {
    path: '/my',
    name: 'my',
    component: () => import('@/views/MyView.vue'),
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ '../views/AboutView.vue'),
  },
  {
    path: '/search_all',
    name: 'search_all',
    component: () => import('@/views/SearchView.vue'),
  },
  {
    path: '/movie_detail',
    name: 'movie_detail',
    component: () => import('@/views/MovieDetail.vue'),
  },
  {
    path: '/404',
    component: () => import('@/views/PageNotFound.vue'),
  },
  {
    path: '*',
    redirect: '/404',
  },
];

const router = new VueRouter({
  routes,
});

export default router;
